#
# Copyright (C) 2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=md5
PKG_VERSION:=1.1.2
PKG_RELEASE:=0

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://luaforge.net/frs/download.php/3355/md5-1.1.2.tar.gz

include $(INCLUDE_DIR)/package.mk

define Package/libmd5-lua
  SUBMENU:=Lua
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=LuaMD5
  URL:=http://www.keplerproject.org/md5/
  DEPENDS:=+lua
endef

define Package/md5/description
	MD5 offers basic cryptographic facilities for Lua 5.1: a hash (digest) function, 
	a pair crypt/decrypt based on MD5 and CFB, and a pair crypt/decrypt based on 
	DES with 56-bit keys. 
endef

define Build/Configure
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)/ \
		LIBDIR="$(TARGET_LDFLAGS)" \
		CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -std=gnu99" \
		LD="$(TARGET_CROSS)ld -shared" \
		all
endef


define Package/libmd5-lua/install
	$(INSTALL_DIR) $(1)/usr/lib/lua/md5
	$(INSTALL_DATA) $(PKG_BUILD_DIR)/src/md5.lua $(1)/usr/lib/lua
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/core.so $(1)/usr/lib/lua/md5
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/des56.so $(1)/usr/lib/lua
endef

$(eval $(call BuildPackage,libmd5-lua))
